package com.example.xiaomi.controller;

import com.example.xiaomi.entity.AdminInfo;
import com.example.xiaomi.entity.contents;
import com.example.xiaomi.entity.topic;
import com.example.xiaomi.service.TopicService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("topic")
@CrossOrigin
public class TopicController {
    @Autowired
    private TopicService service;


    

    /**
     * http://localhost:8080/topic/list1  #输入话题总数
     * @return
     */
    @GetMapping("/list1")
    public List<topic> getTopicAccount(){
        List<topic> topicAccountList = service.findTopicAccount();
        return topicAccountList;
    }

    /**
     * http://localhost:8080/topic/list2 #输出话题相应信息
     * @return
     */
    @GetMapping("/list2")
    public List<topic> getAllTopics(String topic){
        List<topic> topicList = service.findAllTopics(topic);
        return topicList;
    }
    @GetMapping("/list5")
    public List<topic> getAllTopic(String topic){
        List<topic> topicAll = service.findAllTopic(topic);
        return topicAll;
    }

    /**
     * http://localhost:8080/topic/list3#模糊查询
     * @return
     */
    @GetMapping("/list3")
    public List<topic> getTopics(String topic){
        List<topic> topicEvery = service.findTopics(topic);
        return topicEvery;
    }

    /**
     * http://localhost:8080/topic/list4 #模糊查询
     * @return
     */
    @GetMapping("/list4")
    public List<topic> getTopicDate(){
        List<topic> topicDateBy = service.findTopicByDate();
        return topicDateBy;
    }

    /**
     * 分页操作
     * @param pageNum :页数
     * @param pageSize:每页显示数
     * @param topic：话题数
     * @return
     */
    @GetMapping("pages")
    public PageInfo<topic> getPagesTopics(Integer pageNum, Integer pageSize, String topic){
        PageInfo<topic> pageInfo = service.findPageTopic(pageNum,pageSize,topic);
        return pageInfo;
    }

//    @GetMapping("/list")
//    public List<topic> getTopicCount(){
//        List<topic> everytopicCount = service.findTopicCount();
//        return everytopicCount;
//    }




}
